package com.neuedu.hcp.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.hcp.entity.Bed;
import com.neuedu.hcp.entity.RespPageBean;
import com.neuedu.hcp.mapper.BedMapper;
import com.neuedu.hcp.service.IBedService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 第八组
 * @since 2021-04-26
 */
@Service
public class BedServiceImpl extends ServiceImpl<BedMapper, Bed> implements IBedService {
    @Autowired
    BedMapper bedMapper;
    @Override
    public RespPageBean getBedListByPage(Integer currentPage, Integer size, Bed bed) {
        Page<Bed> page = new Page<>(currentPage,size);
        IPage<Bed> bedIPage =bedMapper.getBedListByPage(page,bed);
        RespPageBean respPageBean = new RespPageBean(bedIPage.getTotal(),bedIPage.getRecords());
        return respPageBean;
    }

    @Override
    public int insert(Bed bed) {

        return bedMapper.insert(bed);
    }

}
